#include <bits/stdc++.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>

using namespace std;

//string testFile = "data/1004812/test_data.txt";
//string testFile = "data/2861665_639096/test_data.txt";
//string testFile = "data/3512444_697518/test_data.txt";
string testFile = "data/19630345/test_data.txt";
//string testFile = "data/std/test_data.txt";

string resultFile = "rslt.txt";

typedef struct Node{
	int id;
	uint pay;
	bool operator<(const Node &other)const{
		return id<other.id;
	}
	bool operator==(const Node &other)const{
		return id==other.id;
	}
}Node;

/*构建图需要的变量*/
int account_num = 0;
uint inputs[2*2000000];
uint accts[2*2000000];
vector<Node> G[2000000];
vector<int> RG[2000000];
/**********************/

pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;

/*写文件时需要的变量*/
char account_chars[2000000][12];
short length[2000000];
char buf[77*20000000];
/**********************/

/*线程1变量*/
int head_1;
vector<vector<int>> ans3_1;
vector<vector<int>> ans4_1;
vector<vector<int>> ans5_1;
vector<vector<int>> ans6_1;
vector<vector<int>> ans7_1;
bool vis_1[2000000];
int reachable_1[2000000];
int path_1[7];
int r1=0;
/**********************/

/*线程2变量*/
int head_2;
vector<vector<int>> ans3_2;
vector<vector<int>> ans4_2;
vector<vector<int>> ans5_2;
vector<vector<int>> ans6_2;
vector<vector<int>> ans7_2;
bool vis_2[2000000];
int reachable_2[2000000];
int path_2[7];
int r2=0;
/**********************/

/*线程3变量*/
int head_3;
vector<vector<int>> ans3_3;
vector<vector<int>> ans4_3;
vector<vector<int>> ans5_3;
vector<vector<int>> ans6_3;
vector<vector<int>> ans7_3;
bool vis_3[2000000];
int reachable_3[2000000];
int path_3[7];
int r3=0;
/**********************/

/*线程4变量*/
int head_4;
vector<vector<int>> ans3_4;
vector<vector<int>> ans4_4;
vector<vector<int>> ans5_4;
vector<vector<int>> ans6_4;
vector<vector<int>> ans7_4;
bool vis_4[2000000];
int reachable_4[2000000];
int path_4[7];
int r4=0;
/**********************/

/*线程5变量*/
int head_5;
vector<vector<int>> ans3_5;
vector<vector<int>> ans4_5;
vector<vector<int>> ans5_5;
vector<vector<int>> ans6_5;
vector<vector<int>> ans7_5;
bool vis_5[2000000];
int reachable_5[2000000];
int path_5[7];
int r5=0;
/**********************/

/*线程6变量*/
int head_6;
vector<vector<int>> ans3_6;
vector<vector<int>> ans4_6;
vector<vector<int>> ans5_6;
vector<vector<int>> ans6_6;
vector<vector<int>> ans7_6;
bool vis_6[2000000];
int reachable_6[2000000];
int path_6[7];
int r6=0;
/**********************/

/*线程7变量*/
int head_7;
vector<vector<int>> ans3_7;
vector<vector<int>> ans4_7;
vector<vector<int>> ans5_7;
vector<vector<int>> ans6_7;
vector<vector<int>> ans7_7;
bool vis_7[2000000];
int reachable_7[2000000];
int path_7[7];
int r7=0;
/**********************/

/*线程8变量*/
int head_8;
vector<vector<int>> ans3_8;
vector<vector<int>> ans4_8;
vector<vector<int>> ans5_8;
vector<vector<int>> ans6_8;
vector<vector<int>> ans7_8;
bool vis_8[2000000];
int reachable_8[2000000];
int path_8[7];
int r8=0;
/**********************/


uint parse_1(char** s){
	char *p = *s;
	uint val = *(p++) - '0';
	while(*p != ',') val = 10*val + *(p++) - '0';
	*s = p+1;
	return val;
}
uint parse_2(char** s){
	char *p = *s;
	uint val = *(p++) - '0';
	while(*p != '\r' && *p != '\n') val = 10*val + *(p++) - '0';
	*s = *p=='\r' ? p+2:p+1;
	return val;
}
void parse_to_char(uint a, char *tmp, int &k){
	int n=0;
	do{tmp[n++] = a%10+'0';}while((a/=10)>0);
	reverse(tmp, tmp+n);
	tmp[n++]=',';
	length[k]=n;
}
void loadData_and_createGrap(){
	int fd = open(testFile.c_str(), O_RDONLY);
    int size = lseek(fd, 0, SEEK_END);
    char* p_map =(char*)mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
    close(fd);
	char *p = p_map;
	int n=0;//n表示文件中的记录数
	uint money[2000000];
	while(*p != '\0'){
		inputs[n]=parse_1(&p);
		inputs[n+2000000]=parse_1(&p);
		money[n++]=parse_2(&p);
	}
	memcpy(accts, inputs, 4*n);
	memcpy(accts+n, inputs+2000000, 4*n);  
	sort(accts, accts+2*n);//排序
	account_num = unique(accts, accts+2*n) - accts;//去重
	cout<<"account_num = "<<account_num<<endl;
	unordered_map<uint, int> idHash;
	for(int i=0; i<account_num; i++)idHash[accts[i]]=i;
	Node node;
	for(int i=0,a=0,b=0, m=0; i<n; ++i,++m){
		a=idHash[inputs[i+0]];
		b=idHash[inputs[i+2000000]];
		if(a==b) continue;
		G[a].push_back(Node{b,money[m]});
		RG[b].push_back(a);
	}
	for(int i=0; i<account_num; i++) {sort(G[i].begin(),G[i].end());parse_to_char(accts[i],account_chars[i],i);}
	munmap(p_map, size);
}

inline bool check(const uint &x, const uint &y){
	return x<=5ll*y && y<=3ll*x;
}

/*线程1*/
uint pay_1;
void clip_1(int &head, int &cur, int dep){
	int v;
	for(Node &each:G[cur]){
		v = each.id;
		if(v < head || vis_1[v]) continue;
		reachable_1[v] = head;
		if(dep == 2) continue;
		vis_1[cur] = true;
		clip_1(head, v, dep+1);
		vis_1[cur] = false;
	}
}
void rclip_1(int &head, int &cur, int dep){
	for(int &v:RG[cur]){
		if(v < head || vis_1[v]) continue;
		reachable_1[v] = head;
		if(dep == 3) continue;
		vis_1[cur] = true;
		rclip_1(head, v, dep+1);
		vis_1[cur] = false;
	}
}
void dfs_1(int &head, int &cur, Node &last, int dep){
	path_1[dep-1]=cur;
	int v;
	for(Node &each:G[cur]){
		if(dep==1) pay_1=each.pay;//记下这第一笔转账
		if(dep>1 && !check(last.pay, each.pay)) continue;
		v = each.id;
		if(v==head && dep>2){
			if(check(each.pay, pay_1)){
				switch(dep){
					case 3:
						//ans3_1.push_back({path_1[0],path_1[1],path_1[2]});
						r1++;
						break;
					case 4:
						//ans4_1.push_back({path_1[0],path_1[1],path_1[2],path_1[3]});
						r1++;
						break;
					case 5:
						//ans5_1.push_back({path_1[0],path_1[1],path_1[2],path_1[3],path_1[4]});
						r1++;
						break;
					case 6:
						//ans6_1.push_back({path_1[0],path_1[1],path_1[2],path_1[3],path_1[4],path_1[5]});
						r1++;
						break;
				}
			}
			continue;
		}
		if(dep==6 || reachable_1[v]!=head || vis_1[v]) continue;
		vis_1[cur] = true;
		dfs_1(head, v, each, dep+1);
		vis_1[cur] = false;
	}
}
void loop_1(int &u){
	int v1,v2,v3,v4,v5,v6;
	vector<Node>::iterator node7;
	for(Node &node1:G[u]){
		v1=node1.id; if(reachable_1[v1]!=u) continue;
		for(Node &node2:G[v1]){
			v2=node2.id; if(reachable_1[v2]!=u || !check(node1.pay, node2.pay)) continue;
			for(Node &node3:G[v2]){
				v3=node3.id; if(v3<u || v3==v1 || v3==u || !check(node2.pay, node3.pay)) continue;
				for(Node &node4:G[v3]){
					v4=node4.id; if(reachable_1[v4]!=u || v4==v2 || v4==v1 || !check(node3.pay, node4.pay)) continue;
					for(Node &node5:G[v4]){
						v5=node5.id; if(reachable_1[v5]!=u || v5==v3 || v5==v2 || v5==v1  || !check(node4.pay, node5.pay)) continue;
						for(Node &node6:G[v5]){
							v6=node6.id; if(reachable_1[v6]!=u) continue;
							if(!check(node5.pay, node6.pay)||v6==v1 || v6==v2 || v6==v3 || v6==v4) continue;
							node7 = find(G[v6].begin(),G[v6].end(), Node{u,0});
							if(node7==G[v6].end() || !check(node6.pay, node7->pay)) continue;
							if(!check(node7->pay, node1.pay)) continue;
							//ans7_1.push_back({u,v1,v2,v3,v4,v5,v6});
							r1++;
						}
					}
				}
			}
		}
	}
}

/*线程2*/
uint pay_2;
void clip_2(int &head, int &cur, int dep){
	int v;
	for(Node &each:G[cur]){
		v = each.id;
		if(v < head || vis_2[v]) continue;
		reachable_2[v] = head;
		if(dep == 2) continue;
		vis_2[cur] = true;
		clip_2(head, v, dep+1);
		vis_2[cur] = false;
	}
}
void rclip_2(int &head, int &cur, int dep){
	for(int &v:RG[cur]){
		if(v < head || vis_2[v]) continue;
		reachable_2[v] = head;
		if(dep == 3) continue;
		vis_2[cur] = true;
		rclip_2(head, v, dep+1);
		vis_2[cur] = false;
	}
}
void dfs_2(int &head, int &cur, Node &last, int dep){
	path_2[dep-1]=cur;
	int v;
	for(int i=G[cur].size(); i>0; ){//反向遍历，反正很神奇，自己体会吧
		Node &each=G[cur][--i];
		if(dep==1) pay_2=each.pay;//记下这第一笔转账
		if(dep>1 && !check(last.pay, each.pay)) continue;
		v = each.id;
		if(v==head && dep>2){
			if(check(each.pay, pay_2)){
				switch(dep){
					case 3:
						//ans3_2.push_back({path_2[0],path_2[1],path_2[2]});
						r2++;
						break;
					case 4:
						//ans4_2.push_back({path_2[0],path_2[1],path_2[2],path_2[3]});
						r2++;
						break;
					case 5:
						//ans5_2.push_back({path_2[0],path_2[1],path_2[2],path_2[3],path_2[4]});
						r2++;
						break;
					case 6:
						//ans6_2.push_back({path_2[0],path_2[1],path_2[2],path_2[3],path_2[4],path_2[5]});
						r2++;
						break;
				}
			}
			continue;
		}
		if(dep==6 || reachable_2[v]!=head || vis_2[v]) continue;
		vis_2[cur] = true;
		dfs_2(head, v, each, dep+1);
		vis_2[cur] = false;
	}
}
void loop_2(int &u){
	int v1,v2,v3,v4,v5,v6;
	vector<Node>::iterator node7;
	for(auto node1=G[u].rbegin(); node1!=G[u].rend(); ++node1){
		v1=(*node1).id; if(reachable_2[v1]!=u) continue;
		for(auto node2=G[v1].rbegin(); node2!=G[v1].rend(); ++node2){
			v2=(*node2).id; if(reachable_2[v2]!=u || !check((*node1).pay, (*node2).pay)) continue;
			for(auto node3=G[v2].rbegin(); node3!=G[v2].rend(); ++node3){
				v3=(*node3).id; if(v3<u || v3==v1 || v3==u || !check((*node2).pay, (*node3).pay)) continue;
				for(auto node4=G[v3].rbegin(); node4!=G[v3].rend(); ++node4){
					v4=(*node4).id; if(reachable_2[v4]!=u || v4==v2 || v4==v1 || !check((*node3).pay, (*node4).pay)) continue;
					for(auto node5=G[v4].rbegin(); node5!=G[v4].rend(); ++node5){
						v5=(*node5).id; if(reachable_2[v5]!=u || v5==v3 || v5==v2 || v5==v1  || !check((*node4).pay, (*node5).pay)) continue;
						for(auto node6=G[v5].rbegin(); node6!=G[v5].rend(); ++node6){
							v6=(*node6).id; if(reachable_2[v6]!=u) continue;
							if(!check((*node5).pay, (*node6).pay)||v6==v1 || v6==v2 || v6==v3 || v6==v4) continue;
							node7 = find(G[v6].begin(),G[v6].end(), Node{u,0});
							if(node7==G[v6].end() || !check((*node6).pay, node7->pay)) continue;
							if(!check(node7->pay, (*node1).pay)) continue;
							//ans7_2.push_back({u,v1,v2,v3,v4,v5,v6});
							r2++;
						}
					}
				}
			}
		}
	}
}

/*线程3*/
uint pay_3;
void clip_3(int &head, int &cur, int dep){
	int v;
	for(Node &each:G[cur]){
		v = each.id;
		if(v < head || vis_3[v]) continue;
		reachable_3[v] = head;
		if(dep == 2) continue;
		vis_3[cur] = true;
		clip_3(head, v, dep+1);
		vis_3[cur] = false;
	}
}
void rclip_3(int &head, int &cur, int dep){
	for(int &v:RG[cur]){
		if(v < head || vis_3[v]) continue;
		reachable_3[v] = head;
		if(dep == 3) continue;
		vis_3[cur] = true;
		rclip_3(head, v, dep+1);
		vis_3[cur] = false;
	}
}
void dfs_3(int &head, int &cur, Node &last, int dep){
	path_3[dep-1]=cur;
	int v;
	for(Node &each:G[cur]){
		if(dep==1) pay_3=each.pay;//记下这第一笔转账
		if(dep>1 && !check(last.pay, each.pay)) continue;
		v = each.id;
		if(v==head && dep>2){
			if(check(each.pay, pay_3)){
				switch(dep){
					case 3:
						//ans3_3.push_back({path_3[0],path_3[1],path_3[2]});
						r3++;
						break;
					case 4:
						//ans4_3.push_back({path_3[0],path_3[1],path_3[2],path_3[3]});
						r3++;
						break;
					case 5:
						//ans5_3.push_back({path_3[0],path_3[1],path_3[2],path_3[3],path_3[4]});
						r3++;
						break;
					case 6:
						//ans6_3.push_back({path_3[0],path_3[1],path_3[2],path_3[3],path_3[4],path_3[5]});
						r3++;
						break;
				}
			}
			continue;
		}
		if(dep==6 || reachable_3[v]!=head || vis_3[v]) continue;
		vis_3[cur] = true;
		dfs_3(head, v, each, dep+1);
		vis_3[cur] = false;
	}
}
void loop_3(int &u){
	int v1,v2,v3,v4,v5,v6;
	vector<Node>::iterator node7;
	for(Node &node1:G[u]){
		v1=node1.id; if(reachable_3[v1]!=u) continue;
		for(Node &node2:G[v1]){
			v2=node2.id; if(reachable_3[v2]!=u || !check(node1.pay, node2.pay)) continue;
			for(Node &node3:G[v2]){
				v3=node3.id; if(v3<u || v3==v1 || v3==u || !check(node2.pay, node3.pay)) continue;
				for(Node &node4:G[v3]){
					v4=node4.id; if(reachable_3[v4]!=u || v4==v2 || v4==v1 || !check(node3.pay, node4.pay)) continue;
					for(Node &node5:G[v4]){
						v5=node5.id; if(reachable_3[v5]!=u || v5==v3 || v5==v2 || v5==v1  || !check(node4.pay, node5.pay)) continue;
						for(Node &node6:G[v5]){
							v6=node6.id; if(reachable_3[v6]!=u) continue;
							if(!check(node5.pay, node6.pay)||v6==v1 || v6==v2 || v6==v3 || v6==v4) continue;
							node7 = find(G[v6].begin(),G[v6].end(), Node{u,0});
							if(node7==G[v6].end() || !check(node6.pay, node7->pay)) continue;
							if(!check(node7->pay, node1.pay)) continue;
							//ans7_3.push_back({u,v1,v2,v3,v4,v5,v6});
							r3++;
						}
					}
				}
			}
		}
	}
}

/*线程4*/
uint pay_4;
void clip_4(int &head, int &cur, int dep){
	int v;
	for(Node &each:G[cur]){
		v = each.id;
		if(v < head || vis_4[v]) continue;
		reachable_4[v] = head;
		if(dep == 2) continue;
		vis_4[cur] = true;
		clip_4(head, v, dep+1);
		vis_4[cur] = false;
	}
}
void rclip_4(int &head, int &cur, int dep){
	for(int &v:RG[cur]){
		if(v < head || vis_4[v]) continue;
		reachable_4[v] = head;
		if(dep == 3) continue;
		vis_4[cur] = true;
		rclip_4(head, v, dep+1);
		vis_4[cur] = false;
	}
}
void dfs_4(int &head, int &cur, Node &last, int dep){
	path_4[dep-1]=cur;
	int v;
	for(int i=G[cur].size(); i>0; ){//反向遍历，反正很神奇，自己体会吧
		Node &each=G[cur][--i];
		if(dep==1) pay_4=each.pay;//记下这第一笔转账
		if(dep>1 && !check(last.pay, each.pay)) continue;
		v = each.id;
		if(v==head && dep>2){
			if(check(each.pay, pay_4)){
				switch(dep){
					case 3:
						//ans3_4.push_back({path_4[0],path_4[1],path_4[2]});
						r4++;
						break;
					case 4:
						//ans4_4.push_back({path_4[0],path_4[1],path_4[2],path_4[3]});
						r4++;
						break;
					case 5:
						//ans5_4.push_back({path_4[0],path_4[1],path_4[2],path_4[3],path_4[4]});
						r4++;
						break;
					case 6:
						//ans6_4.push_back({path_4[0],path_4[1],path_4[2],path_4[3],path_4[4],path_4[5]});
						r4++;
						break;
				}
			}
			continue;
		}
		if(dep==6 || reachable_4[v]!=head || vis_4[v]) continue;
		vis_4[cur] = true;
		dfs_4(head, v, each, dep+1);
		vis_4[cur] = false;
	}
}
void loop_4(int &u){
	int v1,v2,v3,v4,v5,v6;
	vector<Node>::iterator node7;
	for(auto node1=G[u].rbegin(); node1!=G[u].rend(); ++node1){
		v1=(*node1).id; if(reachable_4[v1]!=u) continue;
		for(auto node2=G[v1].rbegin(); node2!=G[v1].rend(); ++node2){
			v2=(*node2).id; if(reachable_4[v2]!=u || !check((*node1).pay, (*node2).pay)) continue;
			for(auto node3=G[v2].rbegin(); node3!=G[v2].rend(); ++node3){
				v3=(*node3).id; if(v3<u || v3==v1 || v3==u || !check((*node2).pay, (*node3).pay)) continue;
				for(auto node4=G[v3].rbegin(); node4!=G[v3].rend(); ++node4){
					v4=(*node4).id; if(reachable_4[v4]!=u || v4==v2 || v4==v1 || !check((*node3).pay, (*node4).pay)) continue;
					for(auto node5=G[v4].rbegin(); node5!=G[v4].rend(); ++node5){
						v5=(*node5).id; if(reachable_4[v5]!=u || v5==v3 || v5==v2 || v5==v1  || !check((*node4).pay, (*node5).pay)) continue;
						for(auto node6=G[v5].rbegin(); node6!=G[v5].rend(); node6++){
							v6=(*node6).id; if(reachable_4[v6]!=u) continue;
							if(!check((*node5).pay, (*node6).pay)||v6==v1 || v6==v2 || v6==v3 || v6==v4) continue;
							node7 = find(G[v6].begin(),G[v6].end(), Node{u,0});
							if(node7==G[v6].end() || !check((*node6).pay, node7->pay)) continue;
							if(!check(node7->pay, (*node1).pay)) continue;
							//ans7_4.push_back({u,v1,v2,v3,v4,v5,v6});
							r4++;
						}
					}
				}
			}
		}
	}
}

/*线程5*/
uint pay_5;
void clip_5(int &head, int &cur, int dep){
	int v;
	for(Node &each:G[cur]){
		v = each.id;
		if(v < head || vis_5[v]) continue;
		reachable_5[v] = head;
		if(dep == 2) continue;
		vis_5[cur] = true;
		clip_5(head, v, dep+1);
		vis_5[cur] = false;
	}
}
void rclip_5(int &head, int &cur, int dep){
	for(int &v:RG[cur]){
		if(v < head || vis_5[v]) continue;
		reachable_5[v] = head;
		if(dep == 3) continue;
		vis_5[cur] = true;
		rclip_5(head, v, dep+1);
		vis_5[cur] = false;
	}
}
void dfs_5(int &head, int &cur, Node &last, int dep){
	path_5[dep-1]=cur;
	int v;
	for(Node &each:G[cur]){
		if(dep==1) pay_5=each.pay;//记下这第一笔转账
		if(dep>1 && !check(last.pay, each.pay)) continue;
		v = each.id;
		if(v==head && dep>2){
			if(check(each.pay, pay_5)){
				switch(dep){
					case 3:
						ans3_5.push_back({path_5[0],path_5[1],path_5[2]});r5++;
						break;
					case 4:
						ans4_5.push_back({path_5[0],path_5[1],path_5[2],path_5[3]});r5++;
						break;
					case 5:
						ans5_5.push_back({path_5[0],path_5[1],path_5[2],path_5[3],path_5[4]});r5++;
						break;
					case 6:
						ans6_5.push_back({path_5[0],path_5[1],path_5[2],path_5[3],path_5[4],path_5[5]});r5++;
						break;
				}
			}
			continue;
		}
		if(dep==6 || reachable_5[v]!=head || vis_5[v]) continue;
		vis_5[cur] = true;
		dfs_5(head, v, each, dep+1);
		vis_5[cur] = false;
	}
}
void loop_5(int &u){
	int v1,v2,v3,v4,v5,v6;
	vector<Node>::iterator node7;
	for(Node &node1:G[u]){
		v1=node1.id; if(reachable_5[v1]!=u) continue;
		for(Node &node2:G[v1]){
			v2=node2.id; if(reachable_5[v2]!=u || !check(node1.pay, node2.pay)) continue;
			for(Node &node3:G[v2]){
				v3=node3.id; if(v3<u || v3==v1 || v3==u || !check(node2.pay, node3.pay)) continue;
				for(Node &node4:G[v3]){
					v4=node4.id; if(reachable_5[v4]!=u || v4==v2 || v4==v1 || !check(node3.pay, node4.pay)) continue;
					for(Node &node5:G[v4]){
						v5=node5.id; if(reachable_5[v5]!=u || v5==v3 || v5==v2 || v5==v1  || !check(node4.pay, node5.pay)) continue;
						for(Node &node6:G[v5]){
							v6=node6.id; if(reachable_5[v6]!=u) continue;
							if(!check(node5.pay, node6.pay)||v6==v1 || v6==v2 || v6==v3 || v6==v4) continue;
							node7 = find(G[v6].begin(),G[v6].end(), Node{u,0});
							if(node7==G[v6].end() || !check(node6.pay, node7->pay)) continue;
							if(!check(node7->pay, node1.pay)) continue;
							ans7_5.push_back({u,v1,v2,v3,v4,v5,v6});r5++;
						}
					}
				}
			}
		}
	}
}

/*线程6*/
uint pay_6;
void clip_6(int &head, int &cur, int dep){
	int v;
	for(Node &each:G[cur]){
		v = each.id;
		if(v < head || vis_6[v]) continue;
		reachable_6[v] = head;
		if(dep == 2) continue;
		vis_6[cur] = true;
		clip_6(head, v, dep+1);
		vis_6[cur] = false;
	}
}
void rclip_6(int &head, int &cur, int dep){
	for(int &v:RG[cur]){
		if(v < head || vis_6[v]) continue;
		reachable_6[v] = head;
		if(dep == 3) continue;
		vis_6[cur] = true;
		rclip_6(head, v, dep+1);
		vis_6[cur] = false;
	}
}
void dfs_6(int &head, int &cur, Node &last, int dep){
	path_6[dep-1]=cur;
	int v;
	for(int i=G[cur].size(); i>0; ){//反向遍历，反正很神奇，自己体会吧
		Node &each=G[cur][--i];
		if(dep==1) pay_6=each.pay;//记下这第一笔转账
		if(dep>1 && !check(last.pay, each.pay)) continue;
		v = each.id;
		if(v==head && dep>2){
			if(check(each.pay, pay_6)){
				switch(dep){
					case 3:
						ans3_6.push_back({path_6[0],path_6[1],path_6[2]});r6++;
						break;
					case 4:
						ans4_6.push_back({path_6[0],path_6[1],path_6[2],path_6[3]});r6++;
						break;
					case 5:
						ans5_6.push_back({path_6[0],path_6[1],path_6[2],path_6[3],path_6[4]});r6++;
						break;
					case 6:
						ans6_6.push_back({path_6[0],path_6[1],path_6[2],path_6[3],path_6[4],path_6[5]});r6++;
						break;
				}
			}
			continue;
		}
		if(dep==6 || reachable_6[v]!=head || vis_6[v]) continue;
		vis_6[cur] = true;
		dfs_6(head, v, each, dep+1);
		vis_6[cur] = false;
	}
}
void loop_6(int &u){
	int v1,v2,v3,v4,v5,v6;
	vector<Node>::iterator node7;
	for(auto node1=G[u].rbegin(); node1!=G[u].rend(); ++node1){
		v1=(*node1).id; if(reachable_6[v1]!=u) continue;
		for(auto node2=G[v1].rbegin(); node2!=G[v1].rend(); ++node2){
			v2=(*node2).id; if(reachable_6[v2]!=u || !check((*node1).pay, (*node2).pay)) continue;
			for(auto node3=G[v2].rbegin(); node3!=G[v2].rend(); ++node3){
				v3=(*node3).id; if(v3<u || v3==v1 || v3==u || !check((*node2).pay, (*node3).pay)) continue;
				for(auto node4=G[v3].rbegin(); node4!=G[v3].rend(); ++node4){
					v4=(*node4).id; if(reachable_6[v4]!=u || v4==v2 || v4==v1 || !check((*node3).pay, (*node4).pay)) continue;
					for(auto node5=G[v4].rbegin(); node5!=G[v4].rend(); ++node5){
						v5=(*node5).id; if(reachable_6[v5]!=u || v5==v3 || v5==v2 || v5==v1  || !check((*node4).pay, (*node5).pay)) continue;
						for(auto node6=G[v5].rbegin(); node6!=G[v5].rend(); ++node6){
							v6=(*node6).id; if(reachable_6[v6]!=u) continue;
							if(!check((*node5).pay, (*node6).pay)||v6==v1 || v6==v2 || v6==v3 || v6==v4) continue;
							node7 = find(G[v6].begin(),G[v6].end(), Node{u,0});
							if(node7==G[v6].end() || !check((*node6).pay, node7->pay)) continue;
							if(!check(node7->pay, (*node1).pay)) continue;
							ans7_6.push_back({u,v1,v2,v3,v4,v5,v6});r6++;
						}
					}
				}
			}
		}
	}
}

/*线程7*/
uint pay_7;
void clip_7(int &head, int &cur, int dep){
	int v;
	for(Node &each:G[cur]){
		v = each.id;
		if(v < head || vis_7[v]) continue;
		reachable_7[v] = head;
		if(dep == 2) continue;
		vis_7[cur] = true;
		clip_7(head, v, dep+1);
		vis_7[cur] = false;
	}
}
void rclip_7(int &head, int &cur, int dep){
	for(int &v:RG[cur]){
		if(v < head || vis_7[v]) continue;
		reachable_7[v] = head;
		if(dep == 3) continue;
		vis_7[cur] = true;
		rclip_7(head, v, dep+1);
		vis_7[cur] = false;
	}
}
void dfs_7(int &head, int &cur, Node &last, int dep){
	path_7[dep-1]=cur;
	int v;
	for(Node &each:G[cur]){
		if(dep==1) pay_7=each.pay;//记下这第一笔转账
		if(dep>1 && !check(last.pay, each.pay)) continue;
		v = each.id;
		if(v==head && dep>2){
			if(check(each.pay, pay_7)){
				switch(dep){
					case 3:
						ans3_7.push_back({path_7[0],path_7[1],path_7[2]});r7++;
						break;
					case 4:
						ans4_7.push_back({path_7[0],path_7[1],path_7[2],path_7[3]});r7++;
						break;
					case 5:
						ans5_7.push_back({path_7[0],path_7[1],path_7[2],path_7[3],path_7[4]});r7++;
						break;
					case 6:
						ans6_7.push_back({path_7[0],path_7[1],path_7[2],path_7[3],path_7[4],path_7[5]});r7++;
						break;
				}
			}
			continue;
		}
		if(dep==6 || reachable_7[v]!=head || vis_7[v]) continue;
		vis_7[cur] = true;
		dfs_7(head, v, each, dep+1);
		vis_7[cur] = false;
	}
}
void loop_7(int &u){
	int v1,v2,v3,v4,v5,v6;
	vector<Node>::iterator node7;
	for(Node &node1:G[u]){
		v1=node1.id; if(reachable_7[v1]!=u) continue;
		for(Node &node2:G[v1]){
			v2=node2.id; if(reachable_7[v2]!=u || !check(node1.pay, node2.pay)) continue;
			for(Node &node3:G[v2]){
				v3=node3.id; if(v3<u || v3==v1 || v3==u || !check(node2.pay, node3.pay)) continue;
				for(Node &node4:G[v3]){
					v4=node4.id; if(reachable_7[v4]!=u || v4==v2 || v4==v1 || !check(node3.pay, node4.pay)) continue;
					for(Node &node5:G[v4]){
						v5=node5.id; if(reachable_7[v5]!=u || v5==v3 || v5==v2 || v5==v1  || !check(node4.pay, node5.pay)) continue;
						for(Node &node6:G[v5]){
							v6=node6.id; if(reachable_7[v6]!=u) continue;
							if(!check(node5.pay, node6.pay)||v6==v1 || v6==v2 || v6==v3 || v6==v4) continue;
							node7 = find(G[v6].begin(),G[v6].end(), Node{u,0});
							if(node7==G[v6].end() || !check(node6.pay, node7->pay)) continue;
							if(!check(node7->pay, node1.pay)) continue;
							ans7_7.push_back({u,v1,v2,v3,v4,v5,v6});r7++;
						}
					}
				}
			}
		}
	}
}

/*线程8*/
uint pay_8;
void clip_8(int &head, int &cur, int dep){
	int v;
	for(Node &each:G[cur]){
		v = each.id;
		if(v < head || vis_8[v]) continue;
		reachable_8[v] = head;
		if(dep == 2) continue;
		vis_8[cur] = true;
		clip_8(head, v, dep+1);
		vis_8[cur] = false;
	}
}
void rclip_8(int &head, int &cur, int dep){
	for(int &v:RG[cur]){
		if(v < head || vis_8[v]) continue;
		reachable_8[v] = head;
		if(dep == 3) continue;
		vis_8[cur] = true;
		rclip_8(head, v, dep+1);
		vis_8[cur] = false;
	}
}
void dfs_8(int &head, int &cur, Node &last, int dep){
	path_8[dep-1]=cur;
	int v;
	for(int i=G[cur].size(); i>0; ){//反向遍历，反正很神奇，自己体会吧
		Node &each=G[cur][--i];
		if(dep==1) pay_8=each.pay;//记下这第一笔转账
		if(dep>1 && !check(last.pay, each.pay)) continue;
		v = each.id;
		if(v==head && dep>2){
			if(check(each.pay, pay_8)){
				switch(dep){
					case 3:
						ans3_8.push_back({path_8[0],path_8[1],path_8[2]});r8++;
						break;
					case 4:
						ans4_8.push_back({path_8[0],path_8[1],path_8[2],path_8[3]});r8++;
						break;
					case 5:
						ans5_8.push_back({path_8[0],path_8[1],path_8[2],path_8[3],path_8[4]});r8++;
						break;
					case 6:
						ans6_8.push_back({path_8[0],path_8[1],path_8[2],path_8[3],path_8[4],path_8[5]});r8++;
						break;
				}
			}
			continue;
		}
		if(dep==6 || reachable_8[v]!=head || vis_8[v]) continue;
		vis_8[cur] = true;
		dfs_8(head, v, each, dep+1);
		vis_8[cur] = false;
	}
}
void loop_8(int &u){
	int v1,v2,v3,v4,v5,v6;
	vector<Node>::iterator node7;
	for(auto node1=G[u].rbegin(); node1!=G[u].rend(); ++node1){
		v1=(*node1).id; if(reachable_8[v1]!=u) continue;
		for(auto node2=G[v1].rbegin(); node2!=G[v1].rend(); ++node2){
			v2=(*node2).id; if(reachable_8[v2]!=u || !check((*node1).pay, (*node2).pay)) continue;
			for(auto node3=G[v2].rbegin(); node3!=G[v2].rend(); ++node3){
				v3=(*node3).id; if(v3<u || v3==v1 || v3==u || !check((*node2).pay, (*node3).pay)) continue;
				for(auto node4=G[v3].rbegin(); node4!=G[v3].rend(); ++node4){
					v4=(*node4).id; if(reachable_8[v4]!=u || v4==v2 || v4==v1 || !check((*node3).pay, (*node4).pay)) continue;
					for(auto node5=G[v4].rbegin(); node5!=G[v4].rend(); ++node5){
						v5=(*node5).id; if(reachable_8[v5]!=u || v5==v3 || v5==v2 || v5==v1  || !check((*node4).pay, (*node5).pay)) continue;
						for(auto node6=G[v5].rbegin(); node6!=G[v5].rend(); ++node6){
							v6=(*node6).id; if(reachable_8[v6]!=u) continue;
							if(!check((*node5).pay, (*node6).pay)||v6==v1 || v6==v2 || v6==v3 || v6==v4) continue;
							node7 = find(G[v6].begin(),G[v6].end(), Node{u,0});
							if(node7==G[v6].end() || !check((*node6).pay, node7->pay)) continue;
							if(!check(node7->pay, (*node1).pay)) continue;
							ans7_8.push_back({u,v1,v2,v3,v4,v5,v6});r8++;
						}
					}
				}
			}
		}
	}
}


void solve_1(void){
	auto start = chrono::steady_clock::now();
	bool flag = false;
	memset(vis_1, 0, sizeof(bool)*account_num);
	memset(reachable_1, -1, sizeof(int)*account_num);
	Node tmp;
	while(1){
		pthread_mutex_lock(&g_mutex);
		if((head_2 - head_1) <= 1) flag=true;
        head_1++;
        pthread_mutex_unlock(&g_mutex);
        if(flag) break;
		if(G[head_1].size()<1 || RG[head_1].size()<1) continue;
		clip_1(head_1,head_1,1);
		rclip_1(head_1,head_1,1);
		dfs_1(head_1,head_1,tmp,1);
		loop_1(head_1);
	}
	auto end = chrono::steady_clock::now();
	double cost_t = chrono::duration<double,std::milli>(end-start).count()/1000;
	cout << "solve_1 -const- : " << cost_t  << "s" << endl;
}
void solve_2(void){
	auto start = chrono::steady_clock::now();
	bool flag = false;
	memset(vis_2, 0, sizeof(bool)*account_num);
	memset(reachable_2, -1, sizeof(int)*account_num);
	Node tmp;
	while(1){
		pthread_mutex_lock(&g_mutex);
		if((head_2 - head_1) <= 1) flag=true;
        head_2--;
        pthread_mutex_unlock(&g_mutex);
        if(flag) break;
		if(G[head_2].size()<1 || RG[head_2].size()<1) continue;
		clip_2(head_2,head_2,1);
		rclip_2(head_2,head_2,1);
		dfs_2(head_2,head_2,tmp,1);
		loop_2(head_2);
	}
	auto end = chrono::steady_clock::now();
	double cost_t = chrono::duration<double,std::milli>(end-start).count()/1000;
	cout << "solve_2 -const- : " << cost_t  << "s" << endl;
}
void solve_3(void){
	auto start = chrono::steady_clock::now();
	bool flag = false;
	memset(vis_3, 0, sizeof(bool)*account_num);
	memset(reachable_3, -1, sizeof(int)*account_num);
	Node tmp;
	while(1){
		pthread_mutex_lock(&g_mutex);
		if((head_4 - head_3) <= 1) flag=true;
        head_3++;
        pthread_mutex_unlock(&g_mutex);
        if(flag) break;
		if(G[head_3].size()<1 || RG[head_3].size()<1) continue;
		clip_3(head_3,head_3,1);
		rclip_3(head_3,head_3,1);
		dfs_3(head_3,head_3,tmp,1);
		loop_3(head_3);
	}
	auto end = chrono::steady_clock::now();
	double cost_t = chrono::duration<double,std::milli>(end-start).count()/1000;
	cout << "solve_3 -const- : " << cost_t  << "s" << endl;
}
void solve_4(void){
	auto start = chrono::steady_clock::now();
	bool flag = false;
	memset(vis_4, 0, sizeof(bool)*account_num);
	memset(reachable_4, -1, sizeof(int)*account_num);
	Node tmp;
	while(1){
		pthread_mutex_lock(&g_mutex);
		if((head_4 - head_3) <= 1) flag=true;
        head_4--;
        pthread_mutex_unlock(&g_mutex);
        if(flag) break;
		if(G[head_4].size()<1 || RG[head_4].size()<1) continue;
		clip_4(head_4,head_4,1);
		rclip_4(head_4,head_4,1);
		dfs_4(head_4,head_4,tmp,1);
		loop_4(head_4);
	}
	auto end = chrono::steady_clock::now();
	double cost_t = chrono::duration<double,std::milli>(end-start).count()/1000;
	cout << "solve_4 -const- : " << cost_t  << "s" << endl;
}
void solve_5(void){
	auto start = chrono::steady_clock::now();
	bool flag = false;
	memset(vis_5, 0, sizeof(bool)*account_num);
	memset(reachable_5, -1, sizeof(int)*account_num);
	Node tmp;
	while(1){
		pthread_mutex_lock(&g_mutex);
		if((head_6 - head_5) <= 1) flag=true;
        head_5++;
        pthread_mutex_unlock(&g_mutex);
        if(flag) break;
		if(G[head_5].size()<1 || RG[head_5].size()<1) continue;
		clip_5(head_5,head_5,1);
		rclip_5(head_5,head_5,1);
		dfs_5(head_5,head_5,tmp,1);
		loop_5(head_5);
	}
	auto end = chrono::steady_clock::now();
	double cost_t = chrono::duration<double,std::milli>(end-start).count()/1000;
	cout << "solve_5 -const- : " << cost_t  << "s" << endl;
}
void solve_6(void){
	auto start = chrono::steady_clock::now();
	bool flag = false;
	memset(vis_6, 0, sizeof(bool)*account_num);
	memset(reachable_6, -1, sizeof(int)*account_num);
	Node tmp;
	while(1){
		pthread_mutex_lock(&g_mutex);
		if((head_6 - head_5) <= 1) flag=true;
        head_6--;
        pthread_mutex_unlock(&g_mutex);
        if(flag) break;
		if(G[head_6].size()<1 || RG[head_6].size()<1) continue;
		clip_6(head_6,head_6,1);
		rclip_6(head_6,head_6,1);
		dfs_6(head_6,head_6,tmp,1);
		loop_6(head_6);
	}
	auto end = chrono::steady_clock::now();
	double cost_t = chrono::duration<double,std::milli>(end-start).count()/1000;
	cout << "solve_6 -const- : " << cost_t  << "s" << endl;
}
void solve_7(void){
	auto start = chrono::steady_clock::now();
	bool flag = false;
	memset(vis_7, 0, sizeof(bool)*account_num);
	memset(reachable_7, -1, sizeof(int)*account_num);
	Node tmp;
	while(1){
		pthread_mutex_lock(&g_mutex);
		if((head_8 - head_7) <= 1) flag=true;
        head_7++;
        pthread_mutex_unlock(&g_mutex);
        if(flag) break;
		if(G[head_7].size()<1 || RG[head_7].size()<1) continue;
		clip_7(head_7,head_7,1);
		rclip_7(head_7,head_7,1);
		dfs_7(head_7,head_7,tmp,1);
		loop_7(head_7);
	}
	auto end = chrono::steady_clock::now();
	double cost_t = chrono::duration<double,std::milli>(end-start).count()/1000;
	cout << "solve_7 -const- : " << cost_t  << "s" << endl;
}
void solve_8(void){
	auto start = chrono::steady_clock::now();
	bool flag = false;
	memset(vis_8, 0, sizeof(bool)*account_num);
	memset(reachable_8, -1, sizeof(int)*account_num);
	Node tmp;
	while(1){
		pthread_mutex_lock(&g_mutex);
		if((head_8 - head_7) <= 1) flag=true;
        head_8--;
        pthread_mutex_unlock(&g_mutex);
        if(flag) break;
		if(G[head_8].size()<1 || RG[head_8].size()<1) continue;
		clip_8(head_8,head_8,1);
		rclip_8(head_8,head_8,1);
		dfs_8(head_8,head_8,tmp,1);
		loop_8(head_8);
	}
	auto end = chrono::steady_clock::now();
	double cost_t = chrono::duration<double,std::milli>(end-start).count()/1000;
	cout << "solve_8 -const- : " << cost_t  << "s" << endl;
}

/*
void save(){
	int all = ans3_1.size();
	all += ans3_2.size();
	all += ans3_3.size();
	all += ans3_4.size();
	all += ans4_1.size();
	all += ans4_2.size();
	all += ans4_3.size();
	all += ans4_4.size();
	all += ans5_1.size();
	all += ans5_2.size();
	all += ans5_3.size();
	all += ans5_4.size();
	all += ans6_1.size();
	all += ans6_2.size();
	all += ans6_3.size();
	all += ans6_4.size();
	all += ans7_1.size();
	all += ans7_2.size();
	all += ans7_3.size();
	all += ans7_4.size();
	int n=sprintf(buf,"%d\n",all);
	int i;
	
	for(auto &cycle:ans3_1){
		for(int &v:cycle){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(i=ans3_2.size()-1; i>-1; --i){
		for(int &v:ans3_2[i]){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(auto &cycle:ans3_3){
		for(int &v:cycle){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(i=ans3_4.size()-1; i>-1; --i){
		for(int &v:ans3_4[i]){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	
	for(auto &cycle:ans4_1){
		for(int &v:cycle){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(i=ans4_2.size()-1; i>-1; --i){
		for(int &v:ans4_2[i]){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(auto &cycle:ans4_3){
		for(int &v:cycle){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(i=ans4_4.size()-1; i>-1; --i){
		for(int &v:ans4_4[i]){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	
	for(auto &cycle:ans5_1){
		for(int &v:cycle){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(i=ans5_2.size()-1; i>-1; --i){
		for(int &v:ans5_2[i]){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(auto &cycle:ans5_3){
		for(int &v:cycle){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(i=ans5_4.size()-1; i>-1; --i){
		for(int &v:ans5_4[i]){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	
	for(auto &cycle:ans6_1){
		for(int &v:cycle){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(i=ans6_2.size()-1; i>-1; --i){
		for(int &v:ans6_2[i]){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(auto &cycle:ans6_3){
		for(int &v:cycle){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(i=ans6_4.size()-1; i>-1; --i){
		for(int &v:ans6_4[i]){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	
	for(auto &cycle:ans7_1){
		for(int &v:cycle){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(i=ans7_2.size()-1; i>-1; --i){
		for(int &v:ans7_2[i]){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(auto &cycle:ans7_3){
		for(int &v:cycle){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	for(i=ans7_4.size()-1; i>-1; --i){
		for(int &v:ans7_4[i]){
			memcpy(buf+n, account_chars[v], length[v]);
			n+=length[v];
		}
		buf[n-1]='\n';
	}
	
	int fd = open(resultFile.c_str(), O_RDWR|O_CREAT, 0666);
	lseek(fd, n-1, SEEK_SET);
	write(fd, "", 1);
	char* p_map =(char*)mmap(NULL, n, PROT_WRITE, MAP_SHARED, fd, 0);
	memcpy(p_map, buf, n);
	munmap(p_map, n);
	close(fd);
}
*/

int main(int argc, char* argv[]){
	clock_t startTime = clock();
	loadData_and_createGrap();
	clock_t endTime = clock();
	cout << "LoadDataAndCreate: " << (float)(endTime - startTime) / CLOCKS_PER_SEC << " s" << endl;
	
	
	float a[11]={0.05, 0.06, 0.08, 0.1, 0.12, 0.15, 0.18, 0.19, 0.2, 0.22, 0.24};
	//0.05  : 22s
	//0.06  : 21s
	//0.08  : 19s
	//0.10  : 17s
	//0.12  : 16s *best*
	//0.15  : 18s
	//0.18  : 20s
	//0.19  : 20s
	//0.20  : 21s
	//0.22  : 22s
	//0.24  : 22s./
	//float a[11]={0.112, 0.114, 0.116, 0.118};
	//0.112 : 15.6051
	//0.114 : 15.4785 *best*
	//0.116 : 15.6647
	//0.118 : 15.8137
	/*for(int i=0; i<4; i++){
		p3_1=0, p3_2=0, p3_3=0, p3_4=0;
		p4_1=0, p4_2=0, p4_3=0, p4_4=0;
		p5_1=0, p5_2=0, p5_3=0, p5_4=0;
		p6_1=0, p6_2=0, p6_3=0, p6_4=0;
		p7_1=0, p7_2=0, p7_3=0, p7_4=0;
		int all = p3_1+p4_1+p5_1+p6_1+p7_1+p3_2+p4_2+p5_2+p6_2+p7_2+p3_3+p4_3+p5_3+p6_3+p7_3+p3_4+p4_4+p5_4+p6_4+p7_4;
		cout<<"all_loops = "<<all<<endl;
	}*/
	
	// |          |         |||         |          |
	// |h1->  <-h2|h3->  <-h4|h5->  <-h6|h7->  <-h8|  各线程的寻环方向
	// |          |         |||         |          |
	
	/*
	head_1 = -1;
	head_2 = 6000;//12467
	head_3 = head_2 - 1;
	head_4 = 12467;
	head_5 = head_4 -1;
	head_6 = 23890;
	head_7 = head_6 - 1;
	head_8 = account_num;
	*/
	head_1 = -1;
	head_2 = (-1 + account_num*0.28)/3;
	head_3 = head_2 - 1;
	head_4 = account_num*0.28;
	head_5 = head_4 - 1;
	head_6 = head_5 + (account_num - head_5)/9;
	head_7 = head_6 - 1;
	head_8 = account_num;
	//head_1 = -1;
	//head_2 = 12467;//12467
	//cout<<"head_1 = "<<head_1<<endl;
	//cout<<"head_2 = "<<head_2<<endl;
	//cout<<"head_3 = "<<head_3<<endl;
	//cout<<"head_4 = "<<head_4<<endl;
	//cout<<"head_5 = "<<head_5<<endl;
	//cout<<"head_6 = "<<head_6<<endl;
	//cout<<"head_7 = "<<head_7<<endl;
	//cout<<"head_8 = "<<head_8<<endl;
	
	auto start = chrono::steady_clock::now();
	vector<thread> threadpool(8);
	threadpool[0] = thread(&solve_1);
	threadpool[1] = thread(&solve_2);
	threadpool[2] = thread(&solve_3);
	threadpool[3] = thread(&solve_4);
	threadpool[4] = thread(&solve_5);
	threadpool[5] = thread(&solve_6);
	threadpool[6] = thread(&solve_7);
	threadpool[7] = thread(&solve_8);
	for(int j=0; j<8; j++){
		threadpool[j].join();
	}
	auto end = chrono::steady_clock::now();
	double cost_t = chrono::duration<double,std::milli>(end-start).count()/1000;
	cout << "compute : " << cost_t  << "s" << endl;
	
	startTime = clock();
	//save();
	endTime = clock();
	cout << "save: " << (float)(endTime - startTime) / CLOCKS_PER_SEC << " s" << endl;
	
	cout<<endl;
	cout<<"r1 = "<<r1<<endl;
	cout<<"r2 = "<<r2<<endl;
	cout<<"r3 = "<<r3<<endl;
	cout<<"r4 = "<<r4<<endl;
	cout<<"r5 = "<<r5<<endl;
	cout<<"r6 = "<<r6<<endl;
	cout<<"r7 = "<<r7<<endl;
	cout<<"r8 = "<<r8<<endl;
	cout<<"r1+r2+r3+r4 = "<<r1+r2+r3+r4<<endl;
	cout<<"r5+r6+r7+r8 = "<<r5+r6+r7+r8<<endl;
	int all = r1+r2+r3+r4+r5+r6+r7+r8;
	cout<<"all_loops = "<<all<<endl;
	cout<<"3环 ："<<ans3_1.size()+ans3_2.size()+ans3_3.size()+ans3_4.size()+ans3_5.size()+ans3_6.size()+ans3_7.size()+ans3_8.size()<<endl;
	cout<<"4环 ："<<ans4_1.size()+ans4_2.size()+ans4_3.size()+ans4_4.size()+ans4_5.size()+ans4_6.size()+ans4_7.size()+ans4_8.size()<<endl;
	cout<<"5环 ："<<ans5_1.size()+ans5_2.size()+ans5_3.size()+ans5_4.size()+ans5_5.size()+ans5_6.size()+ans5_7.size()+ans5_8.size()<<endl;
	cout<<"6环 ："<<ans6_1.size()+ans6_2.size()+ans6_3.size()+ans6_4.size()+ans6_5.size()+ans6_6.size()+ans6_7.size()+ans6_8.size()<<endl;
	cout<<"7环 ："<<ans7_1.size()+ans7_2.size()+ans7_3.size()+ans7_4.size()+ans7_5.size()+ans7_6.size()+ans7_7.size()+ans7_8.size()<<endl;
	
	exit(0);
}